﻿var dictlist = {
    gridDefine: {
        toolbar: { items: [toolbarBtn.addDicttype] },
        columns: [
            { display: lang.type_ID, name: 'DICTTYPE_ID', minWidth: 100 },
            { display: lang.type_name, name: 'DICTTYPE_NAME', minWidth: 120 },
            { display: lang.operation, name: 'DICTTYPE_ID2', minWidth: 220, align: 'center', render: linkop }
        ],
        url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
        urlType: "QueryDictType"
    },
    init: function () {
        jsPageRender(this, true);
    },
    search: function () {
        jsPageSearch(this);
    }
};

function linkop(value, row, index) {
    var _str = 'dicttypeid=' + row.DICTTYPE_ID;
    return '<span style="padding-right:15px;"><a href="javascript:void(0)" onclick="openPage(\'addDicttype\',\'' + _str + '\');">' + lang.edit + '</a></span><span style="padding-right:15px;"><a href="javascript:void(0)" onclick="deletedicttype(\'' + row.DICTTYPE_ID + '\',\'' + row.DICTTYPE_NAME + '\');">' + lang.delete_ + '</a></span><span style="padding-right:15px;"><a href="javascript:void(0)" onclick="openPage(\'dictitemlist\',\'' + _str + '\');">' + lang.details + '</a></span>';
}

function deletedicttype(dicttypeid,dicttypename) {
    $.extend($.messager.defaults, {
        ok: lang.ok,
        cancel: lang.cancel
    });
    $.confirm(lang.sure_to_delete_the_current_type + "[" + dicttypename + "]", lang.delete_type, function (b) {
        if (b) {
            $.ajaxHandler({
                url: App_Config.TadongUrl + "/AjaxMappingHandler.aspx",
                urlType: "EditDictType",
                model: function () { return $.toJSON({ 'action': 0, 'OldDICTTYPE_ID': dicttypeid }); },
                success: function (data) {
                    $.alert(lang.Successfully_deleted, null, function () { dictlist.search(); });
                }
            });
        }
    });
}